package edu.spec.chenli.Servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintStream;

@WebServlet(name = "Servlet",urlPatterns = "/sl")
public class Servlet extends HttpServlet{
    public void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String username = req.getParameter("username");
        HttpSession session = req.getSession();
        session.setAttribute("username", username);

        req.setCharacterEncoding("UTF-8");
        resp.setContentType("text/html;charSet=UTF-8");
        PrintStream out = new PrintStream(resp.getOutputStream());
        out.println("<html>");
        out.println("<body>");
        out.println("<h1>登录成功</h1>");
        out.println("</body>");
        out.println("</html>");
    }
    //protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    // }

    // protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    //}
}
